package com.dingyh.shopwebbackground.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dingyh.shopwebbackground.entity.Stock;
import com.dingyh.shopwebbackground.mapper.StockMapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.dingyh.shopwebbackground.service.StockService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dingyuhan
 * @since 2023-02-20
 */
@Service
public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements StockService {

    @Autowired
    StockMapper stockMapper;

    public List<Stock> getStockList(String saleid){
        return stockMapper.getStockListBySale(saleid);
    }


    public int getByFlot(String flot){
        LambdaQueryWrapper<Stock> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Stock::getFlot,flot);

        return stockMapper.selectCount(queryWrapper);
    }

    public Stock getQty(String flot) {
        LambdaQueryWrapper<Stock> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Stock::getFlot,flot);
        return stockMapper.selectOne(queryWrapper);
    }

    public List<Stock> selectByGoodsId(Map<String,Object> map){
        return stockMapper.selectByGoodsId(map);
    }

}
